/**
 * Created by IntelliJ IDEA.
 * User: Taras_Brzezinsky
 * Date: 8/29/11
 * Time: 6:02 PM
 * To change this template use File | Settings | File Templates.
 */

import com.sun.corba.se.spi.activation._LocatorImplBase;
import sun.security.krb5.EncryptedData;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.*;

public class TaskB extends Thread {
    public TaskB() {
        this.input = new BufferedReader(new InputStreamReader(System.in));
        this.output = new PrintWriter(System.out);
        this.setPriority(Thread.MAX_PRIORITY);
    }

    private void go(int len, int current) {
        if (len == 10) {
            return;
        } else {
            numbers.add(current * 10 + 4);
            numbers.add(current * 10 + 7);
            go(len + 1, current * 10 + 4);
            go(len + 1, current * 10 + 7);
        }
    }

    static class Segment implements Comparable<Segment> {
        int left, right;

        public Segment(int left, int right) {
            this.left = left;
            this.right = right;
        }

        public int compareTo(TaskB.Segment o) {
            return this.left == o.left ? this.right - o.right : this.left - o.left;
        }
    }


    private void solve() throws Throwable {
        go(1, 0);
        Segment first = new Segment(nextInt(), nextInt()), second = new Segment(nextInt(), nextInt());
        int[] good = new int[1022];
        int n = 0;
        for (int current : numbers) {
            good[n++] = current;
        }
        int k = nextInt();
        Arrays.sort(good);
        long total = (long) (first.right - first.left + 1) * (long) (second.right - second.left + 1);
        long accepted = 0;
        ArrayList<Segment> begin = new ArrayList<Segment>(), end = new ArrayList<Segment>();
        for (int i = 0; i + k <= n; ++i) {
            if (good[i] >= first.left && good[i + k - 1] <= second.right) {
                begin.add(new Segment(0, 0));
                begin.add(new Segment(Math.min(good[i], first.right) - first.left + 1, 1));
                end.add(new Segment(Math.max(good[i + k - 1], second.left) - second.left, 0));
                end.add(new Segment(second.right - second.left + 1, 1));
            }
        }
        long a = 0, b = 0;
        Collections.sort(begin);
        Collections.sort(end);
        int c = 0;
        for (int i = 0; i < begin.size(); ++i) {
            if (Math.max(c, i) > 0)
                a += begin.get(i).left - begin.get(i - 1).left;
            if (begin.get(i).right == 1) {
                ++c;
            } else {
                --c;
            }
        }
        for (int i = 0; i < end.size(); ++i) {
            if (Math.max(c, i) > 0)
                b += end.get(i).left - end.get(i - 1).left;
            if (end.get(i).right == 1) {
                ++c;
            } else {
                --c;
            }
        }
        accepted += a * b;
        begin.clear();
        end.clear();

        for (int i = 0; i + k <= n; ++i) {
            if (good[i] >= second.left && good[i + k - 1] <= first.right) {
                begin.add(new Segment(0, 0));
                begin.add(new Segment(Math.min(good[i], second.right) - second.left + 1, 1));
                end.add(new Segment(Math.max(good[i + k - 1], first.left) - first.left, 0));
                end.add(new Segment(first.right - first.left + 1, 1));
            }
        }
        a = 0;
        b = 0;
        Collections.sort(begin);
        Collections.sort(end);
        c = 0;
        for (int i = 0; i < begin.size(); ++i) {
            if (Math.max(c, i) > 0)
                a += begin.get(i).left - begin.get(i - 1).left;
            if (begin.get(i).right == 1) {
                ++c;
            } else {
                --c;
            }
        }
        for (int i = 0; i < end.size(); ++i) {
            if (Math.max(c, i) > 0)
                b += end.get(i).left - end.get(i - 1).left;
            if (end.get(i).right == 1) {
                ++c;
            } else {
                --c;
            }
        }
        accepted += a * b;
        double answer = accepted;
        output.printf("%.12f", answer / total);

    }

    public void run() {
        try {
            solve();
        } catch (Throwable e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
            System.exit(666);
        } finally {
            output.flush();
            output.close();
        }
    }

    public static void main(String[] args) {
        new TaskB().start();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private String nextToken() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    Set<Integer> numbers = new TreeSet<Integer>();
    private BufferedReader input;
    private PrintWriter output;
    private StringTokenizer tokens = null;
}
